﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Circle.Domain.Interface.Service;
using Circle.Domain.Entity;
using Circle.Domain.Interface.UnitOfWork;
using Circle.Web.ViewModelsClient;
using Circle.Web.ViewModels;
using System.Web.Mvc;
using Circle.Manager;
using Circle.Domain.Model;
using Circle.Web.Drivers.Contract;

namespace Circle.Web.Drivers
{

    /* 
     * 
     * the controller should NOT see ViewMode and Entity , except for ClientModel
       the driver will present the coming viewmodel data to client by clientmodel
       the driver will save data to entities or viewmodel by the coming clientmodel 
     * 
     * 
     */

    /// <summary>
    /// Driver is used to integrate functions for some mode, such as json conversion, etc. 
    /// Driver also need to handle messages for client viewModel process 
    /// Drive also need to provide privilege check for client model.
    ///            service get and save data, even tokenUser a want to save the data of tokenUser b, it should do it.
    ///            driver do right check.
    /// It depends on the services.
    /// </summary>
    public abstract class BaseDriver : IBaseDriver
    {
        protected readonly Setting DefaultSetting;
        protected readonly Dictionary<string, string> LocaleResources;

        
        protected readonly ILoggingService LoggingService;
        protected readonly IUnitOfWorkManager UnitOfWorkManager;
        

        public BaseDriver()
        {
            DefaultSetting = WebCircleConfig.DefaultSetting;
            LocaleResources = WebCircleConfig.LocaleResources;
  
            LoggingService = DependencyResolver.Current.GetService<ILoggingService>();
            UnitOfWorkManager = DependencyResolver.Current.GetService<IUnitOfWorkManager>();
        }

        //protected string[] ParsePropertyOption(string option, bool? upperCase = null)
        //{
        //    if (string.IsNullOrEmpty(option)) return new string[]{};
        //    if (upperCase.HasValue)
        //    {
        //        option = upperCase.Value ? option.ToUpper() : option.ToLower();
        //    }
            
        //    var entries = option.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();

        //    return entries;
        //}


    }

    public abstract class EntityDriver : BaseDriver
    { 
    
    }

}